home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / os2 / raytrace / pov / ftpov21.doc next >
Text File  |  1994-05-25  |  13KB  |  311 lines

  1.                          FASTER THAN POV-RAY
  2.                      (at least on most machines)
  3.                                    
  4.                              Version 2.1
  5.                                    
  6.           A modified, sped-up and unofficial version of the
  7.              Persistence of Vision Ray-Tracer Version 2.2
  8.                                    
  9.                                   by
  10.                              Dieter Bayer
  11.              e-mail: dieter@cip.e-technik.uni-erlangen.de
  12.  
  13.  
  14. INTRODUCTION
  15.  
  16.      Faster than  POV-Ray (FTPOV-Ray)  speeds  up  calulation  of
  17.      images by  using some  kind of  direction cubes  for primary
  18.      rays (the  vista buffer)  and shadow rays (the light buffer)
  19.      at the  cost of  additional preprocessing  time and  greater
  20.      memory usage. The bounding slab hierarchy used by POV-Ray is
  21.      projected onto the viewing plane and each point light source
  22.      a priori.  Thus the  number of  ray/slab-tests  is  reduced.
  23.      Furthermore some  modules have  been modified  to  eliminate
  24.      unnecessary calculations  and automatic  bounding  has  been
  25.      improved.
  26.  
  27.         The modified  source code  in the archive FTPV21S.ZIP may
  28.      only be  distributed together  with this  text and  the file
  29.      POVLEGAL.DOC that  is part  of the official POV-Ray package.
  30.      To use  the source code you'll need the original POV-Ray 2.2
  31.      distribution.
  32.  
  33.         WARNING!!! If  you use FTPOV-Ray you'll do it at your own
  34.      risk!  And   don't  forget   that  the  POV-Ray  team  isn't
  35.      responsible for this version.
  36.  
  37.         If something remains unclear, please drop me a note and I
  38.      will update this file. Any Comments, benchmark tests, ideas,
  39.      bug reports are also welcomed, especially benchmark tests of
  40.      the three different methods (-um?) (Do they make sense?).
  41.  
  42.  
  43. NEW OPTIONS
  44.  
  45.      The following new options have been added to POV-Ray to make
  46.      things switchable at demand (they are not used by default).
  47.  
  48.      +uvb     Use the vista buffer.
  49.  
  50.      +ulb     Use the light buffer.
  51.  
  52.      +usf     Split unclipped  CSG unions  if their  children are
  53.               finite.
  54.  
  55.      +usi     Split all unclipped CSG unions.
  56.  
  57.      +ubq     Use automatic bounding for quadrics.
  58.  
  59.      +upv     Use  'previewing'  (just  draws  object's  bounding
  60.               rectangles; CSG objects are blue, other objects are
  61.               red).
  62.  
  63.      -um1     Method 1: don't use bounding slabs while descending
  64.               the vista/light  buffer tree.  This may  be  faster
  65.               than method 2 for some scenes and/or machines.
  66.  
  67.      -um2     Method 2:  use bounding  slabs on the leaves (i. e.
  68.               the objects  themselves) of  the vista/light buffer
  69.               tree (default method).
  70.  
  71.      -um3     Use bounding  slabs on all nodes of the vista/light
  72.               buffer. This  may(???) be faster on machines with a
  73.               fast(!!!) floating point unit.
  74.  
  75.         If you  use the  vista and/or  light  buffer  you  should
  76.      always specifiy  +ubq and +usf/+usi. And don't forget to use
  77.      the automatic  bounding slabs  (+mb option)  or neither  the
  78.      vista nor  the light  buffer will be used, regardless of the
  79.      specified options. Just play around with the new options and
  80.      see what happens.
  81.  
  82.  
  83. PROBLEMS, DRAWBACKS, THINGS TO KNOW
  84.  
  85.  
  86.      -  Since I  can't guarantee  that FTPOV-Ray works correct in
  87.         all cases  it's a  good idea  to trace  a  scene  at  low
  88.         resolution with  both POV-Ray  and FTPOV-Ray.  If you get
  89.         (nearly) identical images, you can use FTPOV-Ray (keep in
  90.         mind that things like crand and anti-aliasing jitter lead
  91.         to different results every run).
  92.  
  93.      -  Do NOT  use  bounding  objects  that  do  not  completely
  94.         enclose the bounded objects. Otherwise you will get wrong
  95.         results with  FTPOV-Ray. You  shouldn't even do this with
  96.         POV-Ray, because the results are not predictable (instead
  97.         use clipped_by  and bounded_by, as mentioned in POV-Ray's
  98.         documentation).
  99.  
  100.      -  FTPOV-Ray  splits  unclipped  unions  even  if  they  are
  101.         bounded (if  they aren't part of an intersection or merge
  102.         object  of course).
  103.  
  104.      -  The direction  cube  algorithms  and  the  bounding  slab
  105.         technique heavily  depend on  finite objects.  You should
  106.         use them whenever possible.
  107.  
  108.      -  FTPOV-Ray calculates  a better (but not perfect) bounding
  109.         box around  CSG intersections than POV-Ray does. Thus you
  110.         don't have to bound intersections as long as they contain
  111.         at least  one finite object. Even some intersections that
  112.         weren't boundable  can now  be bounded,  depending on the
  113.         way they  are declared.  Use the normal form for quadrics
  114.         and planes  perpendicular to  the coordinate  axis in the
  115.         object's declaration to get an automatic bound around the
  116.         object. Afterwards  you can  translate, rotate  and scale
  117.         the object as you like.
  118.  
  119.      -  FTPOV-Ray can  bound some  quadric  shapes  if  they  are
  120.         declared in  their normal  form, i. e. f(x,y,z) = A*x*x +
  121.         B*y*y +  C*z*z +  J. It's  the normal  way to declare the
  122.         quadrics in  this form  and translate,  rotate and  scale
  123.         them afterwards  (just look  at SHAPES.INC).  Ellipsoids,
  124.         spheres and  even clipped cylinders and cones can thus be
  125.         bounded. Ellipsoids  (and I  think  cones  and  cylinders
  126.         also)  declared   as  quadric   surfaces  are  faster  to
  127.         intersect than  scaled spheres  (or the new cone/cylinder
  128.         primitive). And  with the new bounding functions quadrics
  129.         will now respond to automatic bounding in most cases.
  130.  
  131.      -  The up, right and direction vectors defined in the camera
  132.         statement have  to be  perpendicular to each other (isn't
  133.         this a  bug in  POV-Ray?). If  you want  to be  sure, use
  134.         look_at as the last vector in the camera definition.
  135.  
  136.  
  137. CHANGES MADE TO POV-RAY MODULES
  138.  
  139.      A little  time can  be saved  by removing some of the vector
  140.      macros used.  The code  might be  easier to  read with these
  141.      macros but  they sometimes  waste time  due  to  unnecessary
  142.      memory transfers  (may depend  on the processor and compiler
  143.      used). A  few  modifications  I  have  made  assume  that  a
  144.      floating  point  multiplication  is  (much)  faster  than  a
  145.      division (true for 387/486/Pentium).
  146.  
  147.      BOUND.C    Made some functions globally.
  148.  
  149.      CSG.C      Modified computation of CSG's bounding box to get
  150.                 a tighter bounding box around intersections.
  151.  
  152.      LIGHTING.C Removed some unnecessary calculations.
  153.  
  154.      PARSE.C    Added calls  to the new bounding box function for
  155.                 quadrics  and   the  new   plane's  bounding  box
  156.                 calculation.
  157.  
  158.      POVRAY.C   Added calls  to new  modules  and  code  for  new
  159.                 options.
  160.  
  161.      QUADRICS.C Added inverted flag to quadrics.
  162.  
  163.      RENDER.C   Added calls to new functions.
  164.  
  165.         For further  details look at the source code and read the
  166.      comments.
  167.  
  168.  
  169. FTPOV-RAY'S STATISTIC
  170.  
  171.      After parsing  the image  description and  preprocessing,  a
  172.      statistic about  the current  image is  printed to  standard
  173.      error ouput  (that's normally  the screen;  if you're  using
  174.      previewing you'll  have to  pipe it into a file or you won't
  175.      be able  to read it). This statistic tells you the following
  176.      details about all objects used in the scene.
  177.  
  178.      sum      Total number of objects.
  179.  
  180.      csg      Number of objects used inside a CSG.
  181.  
  182.      infin    Number of  infinite objects.  These objects  do not
  183.               respond to  automatic bounding an should be avoided
  184.               whenever  possible   (using  bounding  objects  may
  185.               help).  Infinite   objects  used  in  CSG  are  not
  186.               counted.
  187.  
  188.      bound    Number of objects used as bounding objects.
  189.  
  190.      clip     Number of objects used as clipping objects.
  191.  
  192.      bounded  Number of bounded objects.
  193.  
  194.      clipped  Number of clipped objects.
  195.  
  196.         For good  performance  you  should  keep  the  number  of
  197.      infinite objects as small as possible.
  198.  
  199.  
  200. WHERE TO GET THE SOURCE CODE FOR FTPOV-RAY (AND POV-RAY 2.2)?
  201.  
  202.      I have  uploaded the  source code and executables for MS-DOS
  203.      and  OS/2   2.x  to   ftp.informatik.uni-oldenburg.de.   The
  204.      archives are:
  205.  
  206.      FTPV21S.ZIP  Contains the source code for FTPOV-Ray.
  207.  
  208.      FTPV21MS.ZIP Contains  the   32bit  executable   for  MS-DOS
  209.                   compiled  with   DJGPP  1.11  (GCC  2.5.7).  It
  210.                   requires a  386/387, 486  (no SX!)  or Pentium.
  211.                   There seem to be some problems with DJGPP since
  212.                   some scenes  crashed using the original POV-Ray
  213.                   2.2 source code. Be warned!
  214.  
  215.      FTPV21OS.ZIP Contains the  32bit  executable  for  OS/2  2.x
  216.                   compiled with  Eberhard Mattes  GCC port called
  217.                   emx (also  runs under  MS-DOS). It  requires  a
  218.                   386/387, 486  (no SX!)  or Pentium  and has  no
  219.                   display capabilities.
  220.  
  221.         In addition to the source code for FTPOV-Ray you need the
  222.      original  POV-Ray   source  code  that  are  available  over
  223.      Internet  by   anonymous  FTP   from  alfred.ccs.carleton.ca
  224.      (134.117.1.1). There  you'll also  find most  of the  scenes
  225.      used in the benchmark tests.
  226.  
  227.  
  228. HOW TO COMPILE THE SOURCE CODE?
  229.  
  230.      The source  code for  FTPOV-Ray is compiled in a similar way
  231.      to the  original POV-Ray  source code. You have to make sure
  232.      that the  new files  ADDON?.C are  included in your Makefile
  233.      (they use  ADDON.H), and  the original files are replaced by
  234.      the new ones. To use the new code you'll also have to define
  235.      the flag  'DB_CODE'. You  can use  a compiler switch (e.g. -
  236.      DDB_CODE with  gcc) to  do this  or modify  the file FRAME.H
  237.      (the  line   "#define  DB_CODE"   is  already   included  in
  238.      FRAME.H!).
  239.  
  240.         Besides  the   modifications  and  the  three  new  files
  241.      (ADDON0.C,  ADDON1.C,   ADDON2.C,  ADDON3.C,   ADDON.H)  the
  242.      archive only  contains the  modified files  of  the  POV-Ray
  243.      source code.
  244.  
  245.  
  246. REFERENCES
  247.  
  248.      The following  articles  gave  me  the  ideas  for  the  new
  249.      algorithms:
  250.  
  251.      -  The vista projection was taken from:
  252.  
  253.         A. Hashimoto, T. Akimoto, K. Mase, and Y. Suenaga, "Vista
  254.         Ray-Tracing: High  Speed Ray  Tracing  Using  Perspective
  255.         Projection Image",  New Advances  in  Computer  Graphics,
  256.         Proceedings of  CG International  '89, R. A. Earnshaw, B.
  257.         Wyvill (Eds.), Springer, ..., pp. 549-560
  258.  
  259.      -  The idea for the light buffer was taken from:
  260.  
  261.         E. Haines  and D. Greenberg, "The Light Buffer: A Shadow-
  262.         Testing Accelerator",  IEEE CG&A,  Vol. 6,  No. 9,  Sept.
  263.         1986, pp. 6-16
  264.  
  265.  
  266. HISTORY
  267.  
  268.      Version 1.0
  269.          -  First public release.
  270.  
  271.      Version 2.0
  272.          -  Redesign of the vista buffer and the light buffer.
  273.          -  Fixed some bugs.
  274.          -  Made changes to the readme file.
  275.          -  Made modifications/additions  switchable  at  compile
  276.             time.
  277.          -  Removed object and light source limits.
  278.          -  Made  some   changes  in   QUADRICS.C  (inside  test,
  279.             inverted flag).
  280.          -  Fixed problem  with slow  tracing of unmodified scene
  281.             files (like FISH13.POV or IONIC5.POV).
  282.          -  Added options  to turn the vista and the light buffer
  283.             on/off.
  284.          -  Added options to turn union splitting on/off.
  285.          -  Added a  function  for  automatic  bounding  of  most
  286.             quadric shapes.
  287.          -  Added option  to turn automatic bounding for quadrics
  288.             on/off.
  289.          -  Added option to turn 'previewing' on/off.
  290.          -  Changed   bounding    box    calculation    of    CSG
  291.             intersections.
  292.          -  Changed bounding  box structure  to a  more  suitable
  293.             form.
  294.  
  295.      Version 2.1
  296.          -  Added new method which uses bounding boxes around the
  297.             leafs of  the vista/light tree and the priority queue
  298.             to keep number of ray/object-intersections nearly the
  299.             same compared to POV-Ray 2.2.
  300.          -  Changed the recursion used to descend the vista/light
  301.             buffer tree to a queue.
  302.          -  Added option  to choose  in which way the vista/light
  303.             buffer tree is descended.
  304.          -  Switched back  to original bounding structure because
  305.             different (and  worser) hierarchies were created with
  306.             the new  structure (why  this happend  is  beyond  my
  307.             understanding).
  308.          -  Fixed some bugs.
  309.          -  Sped up creation of vista and light buffer.
  310.          -  Reduced memory used by the light buffer.
  311.